package cn.lvji.springboot.learn.exception.controller;

import cn.lvji.springboot.learn.exception.exception.MyException;
import cn.lvji.springboot.learn.exception.exception.MyException2;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @RequestMapping("/test/e1")
    public String exception1(){
        int i = 1/0;
        return "OK";
    }

    @RequestMapping("/test/throw")
    public String exception2() throws Throwable {
        throw new RuntimeException("abcd");
    }

    @RequestMapping("/tests/{id}")
    public String exception4(@PathVariable("id") int a)  {
        return "ok";
    }

    @RequestMapping("/test/myeception1")
    public String myExc1(){
        throw new MyException("aaa");
    }

    @RequestMapping("/test/myeception2")
    public String myExc2(){
        throw new MyException2("aaa");
    }
}
